Skip to main content

atan2

Type

function

Summary

Returns the arc tangent of one number divided by another, using the sign of both.

Syntax

atan2(<yCoordinate>, <xCoordinate>)

Description

Use the atan2 function to find the arc tangent of one number divided by another when sign is significant.

In most cases, atan2(y,x) is equal to atan(y/x). However, if both x and y are negative, the sign of x/y is positive. In this case, the atan function returns an angle in the first quadrant, but the atan2 function returns an angle in the third quadrant.

If a math operation on finite inputs produces a non-finite output, an execution error is thrown. See math operations for more information.

Parameters

NameTypeDescription

yCoordinate

A number or an expression that evaluates to a number.

xCoordinate

A number or an expression that evaluates to a number.

Examples

atan2(-1,-1) -- returns 4/3 * pi
atan2(thisNumber,thatNumber)

Value

NameTypeDescription

return

The atan2 function returns a number between -pi and pi.

the result

The result of the atan2 function is returned in radians. To get this result in degrees, use the following custom function:

    function atan2InDegrees pFirstArg,pSecondArg
return atan2(pFirstArg,pSecondArg) * 180 / pi
end atan2InDegrees

constant: pi

control structure: function

glossary: sign, radian, custom function, return, degree, math operation

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?